var detector = navigator.userAgent,
    isAndroid = /Android (\d+\.\d+)/.test(detector),
    version = parseFloat(RegExp.$1),
    phoneScale = parseInt(window.screen.width)/750;
if(isAndroid){
  if(version>2.3){
    document.write('<meta name="viewport" content="width=750, minimum-scale = '+ phoneScale +', maximum-scale = '+ phoneScale +', target-densitydpi=device-dpi">');
  }else{
    document.write('<meta name="viewport" content="width=750, target-densitydpi=device-dpi">');
  }
}else{
  document.write('<meta name="viewport" content="width=750, user-scalable=no, target-densitydpi=device-dpi">');
}
//微信去掉下方刷新栏
if(navigator.userAgent.indexOf('MicroMessenger') >= 0){
  document.addEventListener('WeixinJSBridgeReady', function() {
    //WeixinJSBridge.call('hideToolbar');
  });
}

//获取地址栏参数
function GetURL(name) {
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  var r = window.location.search.substr(1).match(reg);
  if(r != null) return unescape(r[2]);
  return null;
}

//移动端弹框
function danger(str,time){
  var node = document.createElement("div");
  node.setAttribute("id","danger")
  node.innerHTML = str;
  node.style.cssText = "position: fixed;padding: 10px 40px;bottom: 20%;left: 50%;font-size: 28px;-webkit-transform: translate(-50%, -50%);transform: translate(-50%, -50%);color: #fff;background: rgba(0,0,0,.6);border-radius: 10px;white-space: nowrap;z-index:999;"
  document.body.appendChild(node);
  setTimeout(function(){
    document.getElementById("danger").remove();
  },time)
}

//AJAX地址
var myPath = "http://firstclass.net:8081/";
// var myPath = "http://116.62.241.255/";
  // var myPath = "http://www.mzdykt.cn/";

//非空验证
function rule(str){
  if(str.replace(/\s/,"").length!=0){return true;}else{return false;}
}


//接口签名sign
function getsign(){
  var time = new Date().getTime();
  var obj = {};
  obj.sign="83847437837439234394834"+time;
  obj.time = time;
  return obj;
}


//xss攻击屏蔽
function stripscript(s){ 
  //var pattern = new RegExp("[%--`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]")        //格式 RegExp("[在中间定义特殊过滤字符]")
  var pattern = new RegExp("[%--`~!@#$^&*()=|{}':;',\\[\\]<>/?~！@#￥……&*|{}']");
  var rs = ""; 
  for (var i = 0; i < s.length; i++) { 
    rs = rs+s.substr(i, 1).replace(pattern, ''); 
  }
  return rs;
}